
const query = require('../config/connection');

//获取用户列表
async function getUserListService (ctx) {
  let sql = 'SELECT * FROM sys_user';
  try {
    let data = await query(sql)
    ctx.body = {
      "success": true,
      "data": data
    };
  } catch (error) {
    ctx.body = {
      "success": false,
      "message": error
    };
  }
}
//用户登录
async function userLoginService (ctx, params) {
  let sql = `select * from sys_user where login_name = '${params.user}' and password='${params.password}'`;
  try {
    let data = await query(sql)
    ctx.body = {
      "success": true,
      "data": data
    };
  } catch (error) {
    ctx.body = {
      "success": false,
      "message": error
    };
  }
}

module.exports = {
  getUserListService,
  userLoginService
};

